﻿using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace FindMyChamp.Helpers
{
    /// <summary>
    /// This is a type converter for visibility and double values.
    /// </summary>
    public class VisibilityConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            bool visibility = true;

            if (double.Parse(value.ToString()) < 0)
            {
                visibility = false;
            }
            
            return visibility ? Visibility.Visible : Visibility.Collapsed;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            Visibility visibility = (Visibility)value;
            return (visibility == Visibility.Visible);
        }

    }
}
